package com.zretc.api.pojo;

import lombok.Getter;

@Getter
public class Pager {
    private Integer recordCount;//总记录数
    private Integer pageNum;//当前页码
    private Integer pageSize;//每页显示数量
    private Integer pageCount;//共几页
    private Integer startIndex;//limit起始下标

    public Pager(Integer recordCount, Integer pageNum, Integer pageSize) {
        this.recordCount = recordCount;//1201
        this.pageNum = pageNum;//
        this.pageSize = pageSize;//100
        init();
    }
    public void init(){
        this.pageCount = recordCount / pageSize;
        if(recordCount % pageSize != 0)
            pageCount ++;

        if(pageNum <= 0)
            pageNum = 1;
        if(pageNum > pageCount)
            pageNum = pageCount;

        startIndex = (pageNum - 1) * pageSize;

    }
}